﻿using System.ComponentModel;
using System.Reflection;
using System;
namespace Financeiro.Domain.Entities {
    public enum TipoConta {
        [Description("Empréstimo")]
        EMPRESTIMO = 1,

        [Description("Conta")]
        CORRENTE = 2,

        [Description("Cartão")]
        CARTAO = 3
    }

    public static class Helper {
        public static string Description(Enum value) {
            FieldInfo fi = value.GetType().GetField(value.ToString());

            DescriptionAttribute[] attributes =
                (DescriptionAttribute[])fi.GetCustomAttributes(
                typeof(DescriptionAttribute),
                false);

            if (attributes != null &&
                attributes.Length > 0)
                return attributes[0].Description;
            else
                return value.ToString();
        }
    }
}